import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'index',
    component: () => import('../views/LayOut'),
    redirect: '/home',
    children: [
      { path: 'home', name: 'home', component: () => import('../views/Home') },
      { path: 'cart', name: 'cart', component: () => import('../views/Cart') },
      { path: 'user', name: 'user', component: () => import('../views/User') },
    ]
  },
  { path: '/detail/:id', name: 'detail', component: () => import('../views/Detail') },
  { path: '/login', name: 'login', component: () => import('../views/login/login.vue') },
  { path: '/register', name: 'register', component: () => import('../views/login/register.vue') },
  { path: '*', name: '', redirect: '/home', component: () => import('../views/Home') }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

export default router
